#!/usr/bin/env python2_zeno

#   Copyright (c) 2011-2012 Industrial   Light   and   Magic.
#   All   rights   reserved.    Used   under   authorization.
#   This material contains the confidential  and  proprietary
#   information   of   Industrial   Light   and   Magic   and
#   may not be copied in whole or in part without the express
#   written   permission   of  Industrial Light  and   Magic.
#   This  copyright  notice  does  not   imply   publication.

import imath
import alembic
import traceback

testList = []

def archiveOut():
    """write out an archive with an object tree"""

    archive = alembic.Abc.OArchive("iterator.abc")
    childObj = alembic.Abc.OObject(archive.getTop(), "childObj")
    grandChildObj = alembic.Abc.OObject(childObj, "grandChildObj" )

def archiveIn():
    """read in archive with an object tree"""

    archive = alembic.Abc.IArchive("iterator.abc")
    top = archive.getTop()

    # This nested call crashed python interpreter with segmentation fault
    grandChildObject = top.children[0].children[0]

    assert grandChildObject.getName() == "grandChildObj"

def testIteratorBinding():
    archiveOut()
    archiveIn()

testList.append(('testIteratorBinding', testIteratorBinding))

# -------------------------------------------------------------------------
# Main loop

for test in testList:
    funcName = test[0]
    print ""
    print "Running %s" % funcName
    test[1]()
    print "passed"

print ""

